/*
 * Modelibra
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package communication.blog;

import java.util.Date;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.modelibra.IEntities;
import org.modelibra.type.EasyDate;
import org.modelibra.util.OutTester;

import communication.CommunicationTest;

/* ======= import concepts ======= */

import communication.blog.member.Members;	
import communication.blog.member.Member;
import communication.blog.entry.Entries;	
import communication.blog.entry.Entry;

/**
 * Blog model tests.
 * 
 * @author Dzenan Ridjanovic
 * @version 2008-01-31
 */
public class BlogTest {

	private static Log log = LogFactory.getLog(BlogTest.class);

	private Blog blog;
	
	public BlogTest() {
		super();
		try {
			begin();
		} catch (Exception e) {
			log.error("Error in BlogTest(): " + e.getMessage());
		}
	}

	private void begin() throws Exception {
		blog = CommunicationTest.getSingleton().getCommunication().getBlog();
	}
	
	public Blog getBlog() {
		return blog;
	}
	
	private void end() {
		blog.close();
	}
	
	public void outputErrors(IEntities entities, String title) {
		entities.getErrors().output(title);
		entities.getErrors().empty();
	}

	public void outputMessage(String message) {
		OutTester.outputText(message);
	}

	private void initBlog() {
		initMembers();
	}
	
	/* ============================= */
	/* ======= SPECIFIC CODE ======= */
	/* ============================= */
	
	private void initMembers() {
		outputMessage("??????? initMembers: creation of Members ???????");

		Members members = blog.getMembers();
		
		outputErrors(members, "Member Add Errors");
	}	
	

	private void test01() {
		outputMessage("??????? test01: test name ???????");
	}

	private void test() {
		test01();
	}

	public static void main(String[] args) {
		BlogTest blogTest = null;
		try {
			blogTest = new BlogTest();
			if (false) {
				blogTest.initBlog();
			}
			blogTest.test();
		} catch (Exception e) {
			log.error("Error in BlogTest.main: " + e.getMessage());
		} finally {
			blogTest.end();
		}
	}

}
